#ifndef __SOCKET_HPP__
#define __SOCKET_HPP__

#include "func.hpp"
#include <cstdlib>
#include <sys/socket.h>

namespace wd{

class Socket{
public:
    Socket(){
        _fd = socket(AF_INET,SOCK_STREAM,0);
        if(_fd < 0){
            perror("socket");
            exit(EXIT_FAILURE);
        }
    }

    Socket(int clientfd)
    :_fd(clientfd){
    }

    ~Socket(){
        close(_fd);
    }

    int fd(){
        return _fd;
    }

private:
    int _fd;
};


}



#endif // __SOCKET_HPP__

